/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 74646
 * Date: 2022-03-26
 * Time: 23:39
 */
//外部类
class OuterClass{
    public int data1 = 1;
    public int data2 = 2;
    //public static int data3 = 3;
    //静态内部类
    static class InnerClass{
//        public int data1 = 999;
//        public int data4 = 4;
//        public int data5 = 5;
//        public static final int data6 = 6;

        //方法一：
        OuterClass out = new OuterClass();

        //方法二
        public  OuterClass outerClass;
        public InnerClass(OuterClass outerClass){
            this.outerClass = outerClass;
        }

        public void test(){
            System.out.println("外部类成员变量："+out.data1); //访问外部类的成员变量
//            System.out.println("内部类成员变量："+this.data1); //访问内部类的成员变量
            System.out.println(outerClass.data2);
//            System.out.println(data3);
//            System.out.println(data4);
//            System.out.println(data5);
//            System.out.println(data6);
        }
    }
    public static void main(String[] args) {
        OuterClass outerClass = new OuterClass();
        OuterClass.InnerClass innerClass = new OuterClass.InnerClass(outerClass);
        innerClass.test();
    }
}


public class Test1 {
}
